<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
		
<ui:composition template="/_template.xhtml">
	<ui:define name="content">
	<div id="tree">
		<h:form>
			<p:tree value="#{treeBean.root}" var="doc" id="tree">
				<p:treeNode expandedIcon="ui-icon-folder-open"
					collapsedIcon="ui-icon-folder-collapsed">
					<h:outputText value="#{doc}" />
				</p:treeNode>

				<p:treeNode type="document" icon="ui-icon-document">
					<h:outputText value="#{doc}" />
				</p:treeNode>
			</p:tree>
		</h:form>
	</div>
	<div id="content">
		<h:form>
			<fieldset>
				<legend>Consultar Usuário</legend>
				<h:panelGrid columns="2">
					<h:outputText for="nome" value="Informe o Nome do Usuário: " />
					<p:inputText id="search-query" value="#{listaUsuarioBean.nome}" />
					
					<h:outputText for="perfil" value="Informe o Perfil " />
					<p:selectOneMenu value="#{listaUsuarioBean.perfil}">  
			            <f:selectItem itemLabel="-- Selecione --" itemValue="" />  
			            <f:selectItem itemLabel="Gerente"    itemValue="1" />  
			            <f:selectItem itemLabel="Analista"   itemValue="2" />  
	       		    </p:selectOneMenu>  
	       		    
					<p:commandButton id="pesquisar" value="Pesquisar"
						action="#{listaUsuarioBean.pesquisar}" />
				</h:panelGrid>
			</fieldset>
			<p:dataTable value="#{listaUsuarioBean.dataModel}" var="user"
				paginator="true" rows="5" dynamic="true">

				<p:column headerText="Nome">
					#{user.nome}
				</p:column>
			
				<p:column headerText="Perfil">
					<h:outputText rendered="#{user.perfil == 1}" value="Gerente" />
					<h:outputText rendered="#{user.perfil == 2}" value="Analista" />
				</p:column>

				<p:column headerText="Login">
					#{user.login}
				</p:column>

				<p:column headerText="Detalhar">
					<h:commandLink action="#{usuarioBean.detalhar(user)}"
						value="Detalhar" />
				</p:column>
			</p:dataTable>
			<p:messages id="messages" showDetail="true" autoUpdate="true" />
		</h:form>
	</div>
	</ui:define>
</ui:composition>
</html>